package com.android.sreader.utility;

import java.util.ArrayList;
import java.util.List;
import android.graphics.drawable.BitmapDrawable;


import com.android.sreader.format.EpubFile;

public class Book{
	public enum BookType{
		epub,rss,greader,twitter,weibo,renren,pdf,txt
	};
	
	private BookType bookType = null;
	private Object bookObject = null;
	private String author = "";
	private String bookName = "";
	private BitmapDrawable bookCover = null;
	private List<Bookmark> bookmarks = new ArrayList<Bookmark>();
    
    public int getCurPage() {
		return curPage;
	}

	public void setCurPage(int curPage) {
		this.curPage = curPage;
	}

	public int getCurChapter() {
		return curChapter;
	}

	public void setCurChapter(int curChapter) {
		this.curChapter = curChapter;
	}

	private int curPage = 0;
    private int curChapter = 0;
	
	public Book(BookType _type,Object _o,String _a,String _b,BitmapDrawable _bd){
		this.bookType 	= _type;
		this.bookObject = _o;
		this.author    	= _a;
		this.bookName  	= _b;
		this.bookCover 	= _bd;
	}
	
	public Book(){
		bookType = null;
		bookObject = null;
		author = "";
		bookName = "";
		bookCover = null;
	}
	
	public boolean initWithPath(String bookPath){
		if(bookPath.toLowerCase().indexOf("epub") > 0){
			bookType = BookType.epub;
			bookObject = new EpubFile(bookPath);
			((EpubFile)bookObject).epubFileInit();
			this.author = ((EpubFile)bookObject).getBookAuthor();
			this.bookName = ((EpubFile)bookObject).getBookName();
			this.bookCover= ((EpubFile)bookObject).getCover();
			return true;
		}
		return false;
	}
	
	public BookType getBookType(){
		return this.bookType;
	}
	
	public String getAuthor(){
		return this.author;
	}
	
	public String getBookName(){
		return this.bookName;
	}
	
	public BitmapDrawable getBookCover(){
		return this.bookCover;
	}
	
	public Paragraph getNextParagraph(){
		return ((EpubFile)bookObject).getNextParagraph();
	}
	
	public List<Paragraph> getNextChapter(){		
		switch(this.bookType){
		case epub:
			return ((EpubFile)bookObject).getNextChapter();
		default:
			return null;
		}
	}
	
	public int getChapterSize(){
		switch(this.bookType){
		case epub:
			return ((EpubFile)bookObject).getChapterSrc().size();
		default:
			return 0;
		}
	}
	
	public List<String> getChapterNames(){
		switch(this.bookType){
		case epub:
			return ((EpubFile)bookObject).getChapterNames();
		default:
			return null;
		}
	}
	
	
	public List<Paragraph> getChapterWithNum(int num){		
		switch(this.bookType){
		case epub:
			return ((EpubFile)bookObject).getChapterWithNum(num);
		default:
			return null;
		}
	}
	
}
